package model

import (
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Username string `gorm:"unique varchar(30)"`
	Password string `gorm:"not null varchar(50)"`
	Nickname string `gorm:"varchar(50)"`
	Status   int    `gorm:"default:0"`
}

func GetByUserName(userName string) User {
	var user User
	DB.Where("username = ?", userName).First(&user)
	return user
}

func (user *User) CreateUser() {
	DB.Create(&user)
}
